using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
using DanielSig.UnityExtensions;
using DanielSig;
using System.Linq;

[CustomEditor(typeof(FOVSensor))]
[CanEditMultipleObjects]
public class FOVSensorInspector : Editor
{	
	private static Color _highlightColor = new Color(0.5F, 0.75F, 1F, 1F);
	
	private static Color[] _sensationColors = new Color[]
	{
		Color.white,
		Color.gray * 1.2F,
		Color.green,
		Color.red + Color.white * 0.75F,
		Color.green + Color.white * 0.6F,
		Color.red * 0.7F + Color.white * 0.3F,
		Color.green - Color.white * 0.25F
	};
	private static String[] _sensationNames;
	
	static FOVSensorInspector()
	{
		int length = (int)SensationType.EnemyAmmo;
		_sensationNames = new String[length];
		for(int i = 0; i < length; i++)
			_sensationNames[i] = ((SensationType)(i+1)).ToString();
	}
	
	public override void OnInspectorGUI()
	{
		FOVSensor sensor = (FOVSensor)target;
		
		EditorGUILayout.BeginHorizontal();
			int sensationIndex = ((int)sensor.TargetType - 1).ClampBetween(0, _sensationNames.Length-1);
			GUI.color = _sensationColors[sensationIndex];
			sensor.TargetType = (SensationType)EditorGUILayout.Popup(sensationIndex, _sensationNames) + 1;
			
			GUI.color = sensor.Remember ? _highlightColor : Color.white;
			sensor.Remember = sensor.Remember != GUILayout.Button("Remember");
		EditorGUILayout.EndHorizontal();
	}
}